package com.sui.bigdata.rtcadmin.configuration;

import com.sui.bigdata.rtcadmin.show.SelectResServer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;

/**
 * @Author YongChen
 * @date 2020/2/28 15:48
 * @description
 * @email yong_chen@sui.com
 */
@Configuration
@Slf4j
public class WebSocketConfig implements DisposableBean {

    @Bean
    public ServerEndpointExporter serverEndpointExporter() {
        log.info("---------- WebSocket 启动完成 ----------");
        return new ServerEndpointExporter();
    }

    @Override
    public void destroy() {
        // 通知关闭 WebSocket 连接
        SelectResServer.closeAllClients();
    }

}
